#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdbool.h>

bool lemonadeChange(int* bills, int billsSize)
{
	int i = 0;
	int a = 0;//10
	int b = 0;//20
	int x = 0;//5
	for (i = 0; i < billsSize; i++)
	{
		if (bills[i] == 5)
		{
			x++;
		}
		if (bills[i] == 10)
		{
			a++;
			x--;
		}
		if (bills[i] == 20)
		{
			b++;
			if (a > 0)
			{
				a--;
				x--;
			}
			else
			{
				x -= 3;
			}
		}
		if (x < 0)
			return false;
	}
	return true;

}